import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;

import java.sql.SQLException;

public class Hello {
    public static void main(String[] args) {
        HikariDataSource ds = new HikariDataSource();
        ds.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/jdbc?characterEncoding=utf-8");
        ds.setUsername("root");
        ds.setPassword("Ddj0302.");
        ds.setMaximumPoolSize(10);
        ds.setMinimumIdle(5);
        ds.setConnectionTimeout(30000);
        ds.setIdleTimeout(600000);
        ds.setMaxLifetime(1800000);
        ds.setPoolName("MyHikariPool");
        HikariConfig config = new HikariConfig();
        config.setDataSource(ds);
        HikariDataSource dataSource = new HikariDataSource(config);

        try {
            if(dataSource.getConnection()!=null){
                System.out.println("连接成功！");
            }else{
                System.out.println("连接失败！");
            }
        }catch (SQLException e){
            throw new RuntimeException(e);
        }



    }
}
